package com.usernet.product.utils;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 日期工具类
 * 
 * @author wangshuaibo
 * 
 */
public class DateUtils {

	static public String getNowTime() {
		Date date = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"yyyy-MM-dd HH:mm:ss");
		return dateFormat.format(date);
	}

	public static String timestampToString(Timestamp time) {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		return df.format(time);
	}
	
	public static Timestamp stringToTimestampBegin(String time) {
		if (time == null || time.trim().equals("")) {
			return null;
		}
		return Timestamp.valueOf(time + " 00:00:00");
	}

	public static Timestamp stringToTimestampEnd(String time) {
		if (time == null || time.trim().equals("")) {
			return null;
		}
		return Timestamp.valueOf(time + " 59:59:59");
	}

	public static String getDate() {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		return df.format(new Date());
	}

}
